<template>
  <li>
    <label>
      <!-- <input type="checkbox" v-model="todo.isDone"/> -->
      <input type="checkbox" :checked="todo.isDone" @click="changeHandle">
      <span :class="{ active: todo.isDone }">{{todo.todoName}}</span >
    </label>
    <button class="btn btn-danger" @click="handle">删除</button>
  </li>
</template>

<script>
import PubSub from 'pubsub-js'
export default {
  props:['todo'],
  methods:{
    handle(){
      PubSub.publish('del',this.todo.id)
    },
    changeHandle(){
      console.log('发布change');
       PubSub.publish('change',this.todo.id)
    }
  }
  
}
</script>

<style>
/*item*/
li {
  list-style: none;
  height: 36px;
  line-height: 36px;
  padding: 0 5px;
  border-bottom: 1px solid #ddd;
}

li label {
  display:flex;
  align-items: center;
  float: left;
  cursor: pointer;
}

li label span.active {
  color: #ccc;
  text-decoration: line-through;
}

li label li input {
  vertical-align: middle;
  margin-right: 6px;
  position: relative;
  top: -1px;
}

li button.btn {
  float: right;
  display: none;
  margin-top: 3px;
}
li:hover button.btn{
  display: block;
}

li:before {
  content: initial;
}

li:last-child {
  border-bottom: none;
}
</style>
